/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.logistics.entity.inboundorder;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.cars.Tcar;
import com.jeesite.modules.base.entity.warehouse.Twarehouse;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 入库单Entity
 *
 * @author LV
 * @version 2021-03-10
 */
@Table(name = "t_inbound_order", alias = "a", columns = {
        @Column(name = "inbound_order_id", attrName = "inboundOrderId", label = "入库单ID", isPK = true),
        @Column(name = "inbound_order_code", attrName = "inboundOrderCode", label = "单据编号", queryType = QueryType.LIKE),
        @Column(name = "service_order_id", attrName = "serviceOrderId", label = "服务订单"),
        @Column(name = "frame_number", attrName = "frameNumber", label = "车架号", queryType = QueryType.LIKE),
        @Column(name = "car_id", attrName = "carId", label = "车辆名称"),
        @Column(name = "to_warehouse_type", attrName = "toWarehouseType", label = "仓库类型"),
        @Column(name = "to_warehouse", attrName = "toWarehouse", label = "仓库名称"),
        @Column(name = "date", attrName = "date", label = "入库时间"),
        @Column(name = "from_warehouse", attrName = "fromWarehouse", label = "原仓库"),
        @Column(name = "outbound_date", attrName = "outboundDate", label = "原库出库时间", isQuery = false),
        @Column(name = "from_warehouse_type", attrName = "fromWarehouseType", label = "原库仓类型"),
        @Column(name = "remarks", attrName = "remarks", label = "备注信息", isQuery = false),
        @Column(name = "outbound_order_id", attrName = "outboundOrderId", label = "出库单"),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "b",
                on = "b.service_order_id = a.service_order_id",
                columns = {
                        @Column(name = "service_order_id", label = "服务订单ID", isPK = true),
                        @Column(name = "service_order_code", label = "服务订单编号"),
                }),

        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Tcar.class, attrName = "tcar", alias = "c",
                on = "c.car_id = a.car_id",
                columns = {
                        @Column(name = "car_id", label = "车辆ID", isPK = true),
                        @Column(name = "car_name", label = "车辆编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Twarehouse.class, attrName = "fWarehouse", alias = "d",
                on = "d.warehouse_id = a.from_warehouse",
                columns = {
                        @Column(name = "warehouse_id", label = "出库仓ID", isPK = true),
                        @Column(name = "warehouse_name", label = "出库编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Twarehouse.class, attrName = "tWarehouse", alias = "e",
                on = "e.warehouse_id = a.to_warehouse",
                columns = {
                        @Column(name = "warehouse_id", label = "目的仓ID", isPK = true),
                        @Column(name = "warehouse_name", label = "目的仓编号"),
                }),
}, orderBy = "a.update_date DESC"
)
public class InboundOrder extends DataEntity<InboundOrder> {

    private static final long serialVersionUID = 1L;
    private String inboundOrderId;        // 入库单ID
    private String inboundOrderCode;        // 单据编号
    private String serviceOrderId;        // 服务订单
    private ServiceOrder serviceOrder;
    private String frameNumber;        // 车架号
    private String carId;        // 车辆名称
    private String toWarehouseType;        // 仓库类型
    private String toWarehouse;        // 仓库名称
    private Date date;        // 入库时间
    private String fromWarehouse;        // 原仓库
    private Date outboundDate;        // 原库出库时间
    private String fromWarehouseType;        // 原库仓类型
    private String outboundOrderId;
    private Tcar tcar;
    private Twarehouse fWarehouse;
    private Twarehouse tWarehouse;

    public InboundOrder() {
        this(null);
    }

    public InboundOrder(String id) {
        super(id);
    }

    public String getInboundOrderId() {
        return inboundOrderId;
    }

    public void setInboundOrderId(String inboundOrderId) {
        this.inboundOrderId = inboundOrderId;
    }

    @Length(min = 0, max = 100, message = "单据编号长度不能超过 100 个字符")
    public String getInboundOrderCode() {
        return inboundOrderCode;
    }

    public void setInboundOrderCode(String inboundOrderCode) {
        this.inboundOrderCode = inboundOrderCode;
    }

    @NotBlank(message = "服务订单不能为空")
    @Length(min = 0, max = 64, message = "服务订单长度不能超过 64 个字符")
    public String getServiceOrderId() {
        return serviceOrderId;
    }

    public void setServiceOrderId(String serviceOrderId) {
        this.serviceOrderId = serviceOrderId;
    }

    @NotBlank(message = "车架号不能为空")
    @Length(min = 0, max = 100, message = "车架号长度不能超过 100 个字符")
    public String getFrameNumber() {
        return frameNumber;
    }

    public void setFrameNumber(String frameNumber) {
        this.frameNumber = frameNumber;
    }

    @Length(min = 0, max = 64, message = "车辆名称长度不能超过 64 个字符")
    public String getCarId() {
        return carId;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }

    @NotBlank(message = "仓库类型不能为空")
    @Length(min = 0, max = 2, message = "仓库类型长度不能超过 2 个字符")
    public String getToWarehouseType() {
        return toWarehouseType;
    }

    public void setToWarehouseType(String toWarehouseType) {
        this.toWarehouseType = toWarehouseType;
    }

    @NotBlank(message = "仓库名称不能为空")
    @Length(min = 0, max = 64, message = "仓库名称长度不能超过 64 个字符")
    public String getToWarehouse() {
        return toWarehouse;
    }

    public void setToWarehouse(String toWarehouse) {
        this.toWarehouse = toWarehouse;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "入库时间不能为空")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Length(min = 0, max = 64, message = "原仓库长度不能超过 64 个字符")
    public String getFromWarehouse() {
        return fromWarehouse;
    }

    public void setFromWarehouse(String fromWarehouse) {
        this.fromWarehouse = fromWarehouse;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getOutboundDate() {
        return outboundDate;
    }

    public void setOutboundDate(Date outboundDate) {
        this.outboundDate = outboundDate;
    }

    @Length(min = 0, max = 2, message = "原库仓类型长度不能超过 2 个字符")
    public String getFromWarehouseType() {
        return fromWarehouseType;
    }

    public void setFromWarehouseType(String fromWarehouseType) {
        this.fromWarehouseType = fromWarehouseType;
    }

    public String getFrameNumber_gte() {
        return sqlMap.getWhere().getValue("frame_number", QueryType.GTE);
    }

    public void setFrameNumber_gte(String frameNumber) {
        sqlMap.getWhere().and("frame_number", QueryType.GTE, frameNumber);
    }

    public String getFrameNumber_lte() {
        return sqlMap.getWhere().getValue("frame_number", QueryType.LTE);
    }

    public void setFrameNumber_lte(String frameNumber) {
        sqlMap.getWhere().and("frame_number", QueryType.LTE, frameNumber);
    }

    public String getCarId_gte() {
        return sqlMap.getWhere().getValue("car_id", QueryType.GTE);
    }

    public void setCarId_gte(String carId) {
        sqlMap.getWhere().and("car_id", QueryType.GTE, carId);
    }

    public String getCarId_lte() {
        return sqlMap.getWhere().getValue("car_id", QueryType.LTE);
    }

    public void setCarId_lte(String carId) {
        sqlMap.getWhere().and("car_id", QueryType.LTE, carId);
    }

    public Date getDate_gte() {
        return sqlMap.getWhere().getValue("date", QueryType.GTE);
    }

    public void setDate_gte(Date date) {
        sqlMap.getWhere().and("date", QueryType.GTE, date);
    }

    public Date getDate_lte() {
        return sqlMap.getWhere().getValue("date", QueryType.LTE);
    }

    public void setDate_lte(Date date) {
        sqlMap.getWhere().and("date", QueryType.LTE, date);
    }

    public ServiceOrder getServiceOrder() {
        return serviceOrder;
    }

    public void setServiceOrder(ServiceOrder serviceOrder) {
        this.serviceOrder = serviceOrder;
    }

    public Tcar getTcar() {
        return tcar;
    }

    public void setTcar(Tcar tcar) {
        this.tcar = tcar;
    }

    public Twarehouse getfWarehouse() {
        return fWarehouse;
    }

    public void setfWarehouse(Twarehouse fWarehouse) {
        this.fWarehouse = fWarehouse;
    }

    public Twarehouse gettWarehouse() {
        return tWarehouse;
    }

    public void settWarehouse(Twarehouse tWarehouse) {
        this.tWarehouse = tWarehouse;
    }

    public String getOutboundOrderId() {
        return outboundOrderId;
    }

    public void setOutboundOrderId(String outboundOrderId) {
        this.outboundOrderId = outboundOrderId;
    }
}